package com.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.entity.Announcement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 公告Mapper接口
 *
 * @author Hospital Management System
 */
@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {

    /**
     * 增加查看次数
     */
    @Update("UPDATE tb_announcement SET view_count = view_count + 1 WHERE id = #{id}")
    void incrementViewCount(@Param("id") Long id);

    /**
     * 增加阅读次数
     */
    @Update("UPDATE tb_announcement SET read_count = read_count + 1 WHERE id = #{id}")
    void incrementReadCount(@Param("id") Long id);

    /**
     * 批量更新状态
     */
    @Update("UPDATE tb_announcement SET status = #{status}, update_time = NOW() WHERE id IN (${ids})")
    void batchUpdateStatus(@Param("ids") String ids, @Param("status") Integer status);
} 